package com.ruoyi.edge.gateway.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.mybatis.core.page.PageQuery;
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
import com.ruoyi.edge.gateway.domain.EquipmentTask;
import com.ruoyi.edge.gateway.service.EquipmentTaskService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 边缘计算设备数据解析任务
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/equipmentTask")
public class EquipmentTaskController extends BaseController {

    private final EquipmentTaskService equipmentTaskService;

    /**
     * 获取列表
     */
    @SaCheckPermission("edge:equipmentTask:listPage")
    @GetMapping("/listPage")
    public TableDataInfo<EquipmentTask> listPage(EquipmentTask equipmentTask, PageQuery pageQuery) {
        return equipmentTaskService.listPage(equipmentTask, pageQuery);
    }

    @SaCheckPermission("edge:equipmentTask:get")
    @GetMapping("/get")
    public R<EquipmentTask> get(String id) {
        return equipmentTaskService.get(id);
    }

    /**
     * 新增
     */
    @SaCheckPermission("edge:equipmentTask:add")
    @PostMapping("add")
    public R<String> add(@RequestBody EquipmentTask equipmentTask) {
        return equipmentTaskService.add(equipmentTask);
    }

    /**
     * 编辑
     */
    @SaCheckPermission("edge:equipmentTask:edit")
    @PutMapping("edit")
    public R<String> edit(@RequestBody EquipmentTask equipmentTask) {
        return equipmentTaskService.edit(equipmentTask);
    }

    /**
     * 删除
     */
    @SaCheckPermission("edge:equipmentTask:remove")
    @DeleteMapping("remove")
    public R<String> remove(String id) {
        return equipmentTaskService.remove(id);
    }

    /**
     * 修改状态
     */
    @SaCheckPermission("edge:equipmentTask:editStatus")
    @PutMapping("editStatus")
    public R<String> editStatus(@RequestParam("id") String id,
                        @RequestParam("status") Integer status) {
        return equipmentTaskService.editStatus(id, status);
    }

}
